Repository navigation
Host core: a comparison session that keeps settings across pairs - #114
Merged
Merged
Conversation
agorischek
force-pushed
the
comparison-session
branch
from
November 20, 2026 23:45
4db9e6f to
ee1e537
Compare
agorischek
force-pushed
the
headless-keys
branch
from
November 20, 2026 23:45
db05ee9 to
b8a696b
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The handler stores rejected changes to controlled settings, causing stale requests to take effect when the controlled prop is later removed.
1 open issue
What changed in this PR
Adds a shared comparison session to the headless host core, replacing duplicated explorer state so user settings persist across comparison pairs.
Changes:
- Introduces
useComparisonSession, shared defaults, and public types. - Migrates both explorers to the hook, adds
initialChangesOnly, and aligns initial-mode handling with offered features. - Documents session usage and adds tests for defaults, presentation overrides, and mode restrictions.
| File | Description |
|---|---|
packages/host/vscode-ui/src/explorer.tsx |
Replaces local settings state with the shared session. |
packages/host/core/test/comparison-session.test.mjs |
Tests defaults, overrides, and initial-mode restrictions. |
packages/host/core/src/ui/explorer.tsx |
Adopts the session, including loop and connector persistence. |
packages/host/core/src/index.ts |
Exports session helpers and types. |
packages/host/core/src/comparison-session.ts |
Implements session defaults, state, and stable handlers. |
docs/guides/host-core.md |
Documents session integration and configurable defaults. |
Review effort: Balanced
agorischek
force-pushed
the
headless-keys
branch
from
November 21, 2026 00:43
b8a696b to
a9c0b36
Compare
agorischek
force-pushed
the
comparison-session
branch
2 times, most recently
from
November 21, 2026 01:37
5e1c6d8 to
c8b3d8b
Compare
agorischek
force-pushed
the
headless-keys
branch
2 times, most recently
from
November 21, 2026 15:19
1378b59 to
cd6a8c1
Compare
agorischek
force-pushed
the
comparison-session
branch
from
November 21, 2026 15:19
c8b3d8b to
0aaa5f1
Compare
agorischek
force-pushed
the
headless-keys
branch
from
November 21, 2026 16:08
cd6a8c1 to
809e9ad
Compare
agorischek
force-pushed
the
comparison-session
branch
from
November 21, 2026 16:08
0aaa5f1 to
23f6ab3
Compare
agorischek
force-pushed
the
headless-keys
branch
from
November 21, 2026 17:39
809e9ad to
ba8e73b
Compare
agorischek
force-pushed
the
comparison-session
branch
2 times, most recently
from
November 21, 2026 18:28
971f433 to
d3a7b0c
Compare
…y UI
The default UI, the VS Code UI and Primer each had their own Space-to-play handler, with different lists of elements
that keep Space and different rules for held keys and enclosing dialogs, their own play-button naming, and three
copies of the arrow, Home and End rule for radio groups and tabs. The core now has them, framework-free:
- `handlePlaybackShortcut` and `isPlaybackShortcut`, with `spaceKeeping` and a `keeps` option for a design system's
custom elements: one press, one toggle; a Space-keeping element that encloses the listener doesn't count; a key
from a portaled overlay is never the shortcut;
- `rovingIndex(key, index, count, orientation?)`;
- `playButton(projection, beforeLabel, afterLabel)`: `{action, direction, label}`.
`spaceTogglesPlayback`, `playLabel`, `handlePlaybackKey` and `playButtonState` keep their names and use them.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A pair picker's view remounts for each new comparison, so the default UI's, the VS Code UI's and Primer's explorers each kept the person's settings above it in their own copy, and the copies had drifted: only the VS Code UI and Primer kept loop and the connector, only the VS Code UI kept the initial mode to the modes offered, and Primer opened in All while the others opened in Changes. `useComparisonSession` (with the pure `comparisonSessionDefaults`) keeps the mode, the swipe divider, highlighting, the scope, find, the connector and loop. Each starts from its `initial…` option, else the definition's `presentation`, else one shared default (the Changes scope among them), and each is controllable. Both explorers use it, and gain `initialChangesOnly`. The default UI's explorer now keeps loop and the connector across pairs too. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…en a change is refused A setting the embedder controls is only requested, as `useControllable` does: the session no longer stores the change, so a refused one doesn't surface once the setting is no longer controlled. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
agorischek
force-pushed
the
headless-keys
branch
from
November 21, 2026 19:07
128bf6f to
1f8053d
Compare
agorischek
force-pushed
the
comparison-session
branch
from
November 21, 2026 19:07
d3a7b0c to
7e5da3c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Stacked on #113 (keyboard), which is stacked on #112 (the view model). This is item G6 of the headless-host plan.
Why
A pair picker's view remounts for each new comparison, so each explorer kept the person's settings above it, in its own copy. The copies were in
ui/explorer.tsx,vscode-ui/src/explorer.tsxand Primer'sexplorer.tsx, about 40–60 lines each, and they had drifted:featuresofferThe user decided the default scope is Changes everywhere. A surface may still choose otherwise through an option: consistent defaults, but configurable.
What's in the core now
useComparisonSession(options)returnsComparisonSessionSettings, controlled values with stable handlers, ready to spread intouseProjectionor a view. It coversmode(absent until chosen, so the renderer's default applies),swipePosition,highlighting,changesOnly,search,connectorandloop.comparisonSessionDefaults(options)is pure, and is where each setting starts:initial…option;presentation;initialChangesOnlychanges it.An initial mode the features don't offer gives way to the first they offer.
Both explorers now call the hook and spread the result. Both gain
initialChangesOnly.Behaviour changes
ComparisonExplorer:features.modesexcludes falls back to the first offered.Primer adopts the hook after the pin bump. Meanwhile, a private PR moves its default scope to Changes.
Docs and tests
docs/guides/host-core.mddocuments the hook and its defaults, next touseComparisonPair.packages/host/core/test/comparison-session.test.mjs(node:test, 3 tests) covers:presentationseeding, withinitial…overriding it;Run locally:
tools check --fast: pass.tscfor core and the VS Code UI: pass.The browser suites run in CI.